<?php

$db = Db::getInstance();


$host = Request::get("host");

$group = Request::get("group");

$sql = "select * from gc_client where group_name = ?";
$data = array($group);

if($host) {
	$sql .= " and host = ?";
	$data[] = $host;
}

$result = $db->query($sql, $data);

$ret = array();
foreach($result['rows'] as $r) {
	try {
		$ret[$r['host']] = RefreshClient::reload($r['host']);
	} catch (Exception $e) {
		$ret[$r['host']] = $e->getMessage();	
	}
}

return array(
	'group' => $group,
	'host' => $host,
	'result' => $ret
);
